package com.jack.blog.jedis;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

@Component
@Aspect
public class JedisAspect {

    @Autowired
    private JedisUtil jedisUtil;

    @Around("execution(public * com.jack.blog.cache.*.*(..))")
    public Object jedis(ProceedingJoinPoint joinPoint)throws Throwable{
        Object result=null;
        try {
            result = joinPoint.proceed();
        }catch (Throwable t){
            t.printStackTrace();
            throw t;
        }finally {
            jedisUtil.closeJedis();
            return result;
        }
    }

}
